home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / winsweep / winsweep.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  9.9 KB  |  352 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00C0FFC0&
  5.    Caption         =   "WinSweep 1.3 - (c)1991 Nils Segerdahl"
  6.    ClientHeight    =   4815
  7.    ClientLeft      =   240
  8.    ClientTop       =   1395
  9.    ClientWidth     =   8760
  10.    Height          =   5220
  11.    Icon            =   WINSWEEP.FRX:0000
  12.    Left            =   180
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   4815
  17.    ScaleWidth      =   8760
  18.    Top             =   1050
  19.    Width           =   8880
  20.    Begin FileListBox File1 
  21.       BackColor       =   &H00C0C0C0&
  22.       Height          =   2370
  23.       Hidden          =   -1  'True
  24.       Left            =   7080
  25.       System          =   -1  'True
  26.       TabIndex        =   0
  27.       Top             =   2280
  28.       Width           =   1575
  29.    End
  30.    Begin DirListBox Dir1 
  31.       BackColor       =   &H00C0C0C0&
  32.       Height          =   1575
  33.       Left            =   7080
  34.       TabIndex        =   2
  35.       Top             =   600
  36.       Width           =   1575
  37.    End
  38.    Begin TextBox Text1 
  39.       BackColor       =   &H00FFFFFF&
  40.       ForeColor       =   &H00000000&
  41.       Height          =   4095
  42.       Left            =   120
  43.       MultiLine       =   -1  'True
  44.       ScrollBars      =   3  'Both
  45.       TabIndex        =   1
  46.       Text            =   " "
  47.       Top             =   600
  48.       Width           =   6855
  49.    End
  50.    Begin DriveListBox Drive1 
  51.       BackColor       =   &H00C0C0C0&
  52.       Height          =   315
  53.       Left            =   7320
  54.       TabIndex        =   3
  55.       Top             =   120
  56.       Width           =   1335
  57.    End
  58.    Begin CommandButton Command6 
  59.       Caption         =   "&?"
  60.       Height          =   375
  61.       Left            =   6720
  62.       TabIndex        =   10
  63.       TabStop         =   0   'False
  64.       Top             =   120
  65.       Width           =   375
  66.    End
  67.    Begin CommandButton Command2 
  68.       Caption         =   "&Quit"
  69.       Height          =   375
  70.       Left            =   6000
  71.       TabIndex        =   9
  72.       TabStop         =   0   'False
  73.       Top             =   120
  74.       Width           =   615
  75.    End
  76.    Begin CommandButton Command5 
  77.       Caption         =   "&Run"
  78.       Height          =   375
  79.       Left            =   5400
  80.       TabIndex        =   7
  81.       TabStop         =   0   'False
  82.       Top             =   120
  83.       Width           =   495
  84.    End
  85.    Begin CommandButton Command4 
  86.       Caption         =   "&Copy"
  87.       Height          =   375
  88.       Left            =   4680
  89.       TabIndex        =   6
  90.       TabStop         =   0   'False
  91.       Top             =   120
  92.       Width           =   615
  93.    End
  94.    Begin CommandButton Command3 
  95.       Caption         =   "&Delete"
  96.       Height          =   375
  97.       Left            =   3840
  98.       TabIndex        =   5
  99.       TabStop         =   0   'False
  100.       Top             =   120
  101.       Width           =   735
  102.    End
  103.    Begin CommandButton Command1 
  104.       Caption         =   "&Save"
  105.       Height          =   375
  106.       Left            =   3000
  107.       TabIndex        =   4
  108.       TabStop         =   0   'False
  109.       Top             =   120
  110.       Width           =   735
  111.    End
  112.    Begin TextBox Text2 
  113.       BackColor       =   &H00C0C0C0&
  114.       Height          =   375
  115.       Left            =   600
  116.       TabIndex        =   8
  117.       TabStop         =   0   'False
  118.       Text            =   " "
  119.       Top             =   120
  120.       Width           =   2295
  121.    End
  122.    Begin PictureBox Picture1 
  123.       BackColor       =   &H00C0FFC0&
  124.       BorderStyle     =   0  'None
  125.       Height          =   495
  126.       Left            =   0
  127.       Picture         =   WINSWEEP.FRX:0302
  128.       ScaleHeight     =   495
  129.       ScaleWidth      =   495
  130.       TabIndex        =   11
  131.       TabStop         =   0   'False
  132.       Top             =   0
  133.       Width           =   495
  134.    End
  135. Sub Command1_Click ()
  136.     saveindex = file1.listindex
  137.     If file1.filename = "" Then
  138.     MsgBox "No file selected"
  139.     Exit Sub
  140.     End If
  141.     If (filesize > FILMAX) Then
  142.     MsgBox "File wold be truncated!"
  143.     Exit Sub
  144.     End If
  145.     tmp$ = "Save file " + file1.filename + " ? "
  146.     rep = MsgBox(tmp$, 36, "SAVE File")
  147.     If rep = 6 Then
  148.     tmp$ = file1.filename
  149.     dotpos = InStr(1, tmp$, ".")
  150.     tmp$ = Left$(tmp$, dotpos)
  151.     On Error GoTo errhand
  152.     Kill tmp$ + "bak"
  153.     On Error GoTo 0
  154.     Name file1.filename As tmp$ + "bak"
  155.     Open file1.filename For Binary As #1
  156.     textstr$ = text1.text
  157.     Put #1, , textstr$
  158.     Close #1
  159.     End If
  160.     file1.Refresh
  161.     file1.listindex = saveindex
  162.     file1.SetFocus
  163.     Exit Sub
  164. errhand:
  165.     Resume Next
  166. End Sub
  167. Sub Command2_Click ()
  168.     tmp$ = "If you like this program, please send" + Chr$(13) + Chr$(10)
  169.     tmp$ = tmp$ + "some money (eg. 25$) to me:" + Chr$(13) + Chr$(10)
  170.     tmp$ = tmp$ + " " + Chr$(13) + Chr$(10)
  171.     tmp$ = tmp$ + "Nils Segerdahl" + Chr$(13) + Chr$(10)
  172.     tmp$ = tmp$ + "Pr
  173. rdsgatan 19B" + Chr$(13) + Chr$(10)
  174.     tmp$ = tmp$ + "S-752 30 Upsala, SWEDEN" + Chr$(13) + Chr$(10)
  175.     tmp$ = tmp$ + " " + Chr$(13) + Chr$(10)
  176.     tmp$ = tmp$ + " " + Chr$(13) + Chr$(10)
  177.     tmp$ = tmp$ + "TERMINATE?" + Chr$(13) + Chr$(10)
  178.     resp% = MsgBox(tmp$, 20, "QUIT")
  179.     If resp% = 6 Then
  180.        End
  181.     End If
  182. End Sub
  183. Sub Command3_Click ()
  184.     saveindex = file1.listindex
  185.     If file1.filename = "" Then
  186.     MsgBox "No file selected"
  187.     Exit Sub
  188.     End If
  189.     tmp$ = "Delete file " + file1.filename + " ? "
  190.     rep = MsgBox(tmp$, 36, "Delete File")
  191.     If rep = 6 Then
  192.     Kill file1.filename
  193.     End If
  194.     file1.Refresh
  195.     file1.listindex = saveindex
  196.     file1.SetFocus
  197. End Sub
  198. Sub Command4_Click ()
  199.     saveindex = file1.listindex
  200.     If file1.filename = "" Then
  201.     MsgBox "No file selected"
  202.     Exit Sub
  203.     End If
  204.     tmp$ = "Copy " + file1.filename + " to "
  205.     tmp$ = InputBox$(tmp$, "Copy file", "")
  206.     screen.mousepointer = 11
  207.     If Len(tmp$) > 0 Then
  208.        Open file1.filename For Binary As #1
  209.        On Error GoTo errhand_cmd4
  210.        Kill tmp$
  211.        On Error GoTo 0
  212.        Open tmp$ For Binary As #2
  213.        i = LOF(1)
  214.        text2.text = "Copying...."
  215.        For j = 1 To i Step 512
  216.         tmp$ = Input$(512, #1)
  217.         Put #2, j, tmp$
  218.        Next j
  219.        text2.text = "Done"
  220.        Close
  221.     End If
  222.     file1.Refresh
  223.     file1.listindex = saveindex
  224.     file1.SetFocus
  225.     screen.mousepointer = 0
  226.     Exit Sub
  227. errhand_cmd4:
  228.     Resume Next
  229. End Sub
  230. Sub Command5_Click ()
  231.     saveindex = file1.listindex
  232.     If file1.filename = "" Then
  233.     MsgBox "No file selected"
  234.     Exit Sub
  235.     End If
  236.     tmp$ = Right$(file1.filename, 4)
  237.     If tmp$ = ".exe" Or tmp$ = ".com" Or tmp$ = ".bat" Then
  238.     res = Shell(file1.filename, 1)
  239.     Else
  240.     MsgBox "File not executable"
  241.     End If
  242.     file1.Refresh
  243.     file1.listindex = saveindex
  244.     file1.SetFocus
  245. End Sub
  246. Sub Command6_Click ()
  247.     form2.Show
  248. End Sub
  249. Sub Dir1_Change ()
  250.     screen.mousepointer = 11
  251.     file1.path = dir1.path
  252.     ChDir dir1.path
  253.     On Error GoTo errh
  254.     file1.listindex = 0
  255.     On Error GoTo 0
  256.     file1.SetFocus
  257.     screen.mousepointer = 0
  258.     Exit Sub
  259. errh:
  260.     Resume Next
  261. End Sub
  262. Sub Drive1_Change ()
  263.     screen.mousepointer = 11
  264.     dir1.path = drive1.drive
  265.     ChDrive (drive1.drive)
  266.     file1.listindex = 0
  267.     file1.SetFocus
  268.     screen.mousepointer = 0
  269. End Sub
  270. Sub errhand ()
  271. End Sub
  272. Sub File1_Click ()
  273.     screen.mousepointer = 11
  274.     filesize = 0
  275.     txtstr$ = String$(FILMAX, " ")
  276.     If Right$(file1.filename, 4) = ".exe" Then
  277.     text2.text = ".EXE file - Not viewable"
  278.     Beep
  279.     text1.text = " "
  280.     ElseIf Right$(file1.filename, 4) = ".com" Then
  281.     text2.text = ".COM file - Not viewable"
  282.     Beep
  283.     text1.text = " "
  284.     ElseIf Right$(file1.filename, 4) = ".bmp" Then
  285.     text2.text = ".bmp file - Not viewable"
  286.     Beep
  287.     text1.text = " "
  288.     ElseIf Right$(file1.filename, 4) = ".dll" Then
  289.     text2.text = ".DLL file - Not viewable"
  290.     Beep
  291.     text1.text = " "
  292.     ElseIf Right$(file1.filename, 4) = ".pcx" Then
  293.     text2.text = ".pcx file - Not viewable"
  294.     Beep
  295.     text1.text = " "
  296.     Else
  297.     Open file1.filename For Binary As #1
  298.     filesize = LOF(1)
  299.     Get #1, , txtstr$
  300.     text1.text = txtstr$
  301.     If filesize > FILMAX Then
  302.         text2.text = file1.filename + " TRUNC " + Str$(filesize) + " byte"
  303.     Else
  304.         text2.text = file1.filename + "  " + Str$(filesize) + " byte"
  305.     End If
  306.     Close #1
  307.     End If
  308.     screen.mousepointer = 0
  309. End Sub
  310. Sub File2_Click ()
  311. End Sub
  312. Sub FileIOdemo ()
  313.     Dim ClientName As String * 20
  314.     NL$ = Chr$(13) + Chr$(10)   ' Define newline.
  315.     ' Make a sample random-access file using the Put statement.
  316.     Msg$ = "Enter a name, using whatever form you like." + NL$ + NL$
  317.     Msg$ = Msg$ + "Press 'Enter' with no name to conclude entry."
  318.     Open "FILEIOX.DAT" For Random As #1 Len = Len(ClientName$)
  319.     ClientName$ = InputBox$(Msg$)   ' Get user input.
  320.     Do While ClientName$ <> String$(20, " ")
  321.     Put #1, , ClientName$   ' Write to file.
  322.     ClientName$ = InputBox$(Msg$)   ' Get user input.
  323.     Loop
  324.     ' Read the sample random-access file using the Get statement.
  325.     Max% = Loc(1)
  326.     If Max% = 0 Then    ' Check if records exist.
  327.     Msg$ = "Your file contains no names." + NL$
  328.     Else
  329.     Msg$ = "Your file contains the following names:" + NL$ + NL$
  330.     End If
  331.     For Indx% = 1 To Max%
  332.     Get #1, Indx%, ClientName$  ' Read from file.
  333.     Msg$ = Msg$ + ClientName$ + NL$
  334.     Next Indx%
  335.     Close #1    ' Close file.
  336.     Msg$ = Msg$ + NL$ + "Choose OK to remove the created test file."
  337.     MsgBox Msg$ ' Display message.
  338.     Kill "FILEIOX.DAT"  ' Remove file from disk.
  339. End Sub
  340. Sub Form_Load ()
  341.     If file1.listcount > -1 Then
  342.        file1.listindex = 0
  343.     End If
  344. End Sub
  345. Sub main ()
  346.     file1.listindex = 0
  347.     file1.SetFocus
  348. End Sub
  349. Sub Picture1_Click ()
  350.     MsgBox "WinSweep by Nils Segerdahl"
  351. End Sub
  352.